#pragma once

#include <stdint.h>

#include <string>
#include <cstring>
#include <fstream>
#include <sstream>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <mutex>
#include <thread>
#include <pthread.h>
#include <filesystem>
#include <memory>

#define _USE_MATH_DEFINES
#include <math.h>

typedef std::thread::id std_thread_id;
namespace fs = std::filesystem;

namespace LuaGui {
	bool IsBigEndian();
	bool IsLittleEndian();
	bool IsDevEnv();

	template<class T>
	static std::string ToString(T& t);

	const std::wstring Utf8ToUnicode(const std::string& utf8);
	const std::string UnicodeToUtf8(const std::wstring& u32s);
	unsigned long long GetTimeStamp();

	std::string GetPlatform();
	bool IsAndroidPlatform();
	bool IsWin32Platform();
	bool IsLinuxPlatform();
	bool IsIosPlatform();
	bool IsMacOSPlatform();
	bool IsWebPlatform();

	class Application;
	Application* GetApplication();
}

#if defined(ANDROID) || defined(__android) || defined(__android__)
#include <android/log.h>
#define LOG_TAG    "native-log"
#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#define LOGW(...)  __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
#define LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGV(...)  __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#else
inline void __print__(...) {}
#define LOGE(...) __print__(__VA_ARGS__)
#define LOGW(...) __print__(__VA_ARGS__)
#define LOGI(...) __print__(__VA_ARGS__)
#define LOGD(...) __print__(__VA_ARGS__)
#define LOGV(...) __print__(__VA_ARGS__)
#endif

